home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / prog / asm_n_z.arj / SIT.DOC < prev    next >
Text File  |  1989-05-26  |  13KB  |  394 lines

  1. ===== WHAT IS "SIT"?
  2.  
  3.   SIT is a utility program for creating, modifying or deleting
  4. strings in the MS-DOS environment.  It overcomes some
  5. limitations of the intrinsic MS-DOS SET command, and provides
  6. additional features as well.
  7.  
  8.  
  9. ===== OKAY, SWELL.  WHAT IS "SET"??
  10.  
  11.   MS-DOS has an intrinsic command called SET for creating and
  12. deleting environment strings.  ("Intrinsic" means that the
  13. command is built into the DOS command interpreter program
  14. COMMAND.COM, rather than existing as a separate program file.)
  15.  
  16.   However, there's a problem with SET -- it only works on the
  17. _current_ copy of the environment strings.
  18.  
  19.   When you first boot up a PC with MS-DOS, a _master_copy_ of
  20. COMMAND.COM is loaded into memory, and this copy creates a
  21. _master_environment_ block.  Each time you run a program under
  22. MS-DOS, COMMAND.COM makes a _new_copy_ of the environment
  23. strings (in a separate memory block) that is used by the program
  24. you run.
  25.  
  26.   SET modifies the _current_ copy of the environment.  When
  27. you're sitting at the command prompt C>, the "current" copy _is_
  28. the MASTER copy.
  29.  
  30.   However, when you run a .BAT file, COMMAND.COM creates a
  31. "working" copy of the environment for use by that .BAT file --
  32. and if the .BAT file has a SET command in it, it's the WORKING
  33. copy that gets modified.
  34.  
  35.   That's great if the environment string you're creating or
  36. modifying is used WITHIN the .BAT file, but if you want the new
  37. environment value to be "permanent" (that is, you want your
  38. changes to survive after the .BAT file terminates), you're out
  39. of luck -- because COMMAND.COM discards the WORKING copy of the
  40. environment strings when the .BAT file completes... and the
  41. MASTER copy doesn't have the changes in it!
  42.  
  43.  
  44.   SET is also pretty simple-minded about its syntax.
  45.  
  46.   If you type the command
  47.  
  48.       SET VOOTIE=SOMETHING
  49.  
  50. and then examine your environment (just type SET without
  51. parameters), you'll see that you've got an entry that says the
  52. variable "VOOTIE" is equal to the value "SOMETHING".  Enter
  53.  
  54.       SET VOOTIE=
  55.  
  56. and that entry will be cleared out of your environment.
  57.  
  58.   Now, if you throw in an extra space, _you_ might not notice,
  59. but SET thinks you're talking about something entirely different!
  60.  
  61.       SET VOOTIE = SOMETHING
  62.  
  63. puts a variable called "VOOTIE " (note the trailing space!)
  64. equal to the value " SOMETHING" (note the _leading_ space!)
  65.  
  66.   As far as MS-DOS is concerned, the environment variables
  67. "VOOTIE" and "VOOTIE " are two completely different, unrelated
  68. variable names (and may have completely different values as
  69. well).  This can easily lead to confused programmers,
  70. particularly when you've been debugging since half past
  71. midnight...
  72.  
  73.   SIT trims the trailing spaces (between the variable name and
  74. the "=" sign), so SET VOOTIE=SOMETHING and SET VOOTIE =SOMETHING
  75. both apply to the environment variable VOOTIE.  However, (since
  76. you may _want_ to embed spaces within the _value_) SIT treats
  77. everything _after_ the "=" sign as significant:
  78.  
  79.           SET VOOTIE = SOMETHING    is not the same as
  80.       SET VOOTIE =SOMETHING
  81.  
  82.             --
  83. ===== WHY IS "SIT" BETTER THAN "SET"?
  84.  
  85.   SIT lets you do everything SET does, but it does it to the
  86. MASTER copy of the environment strings.
  87.  
  88.   SIT also trims trailing spaces off the names of environment
  89. variables, so you don't accidentally create a new variable that
  90. isn't what you thought it was. (See above.)
  91.  
  92.   SIT provides three new syntax forms that allow you to
  93.  
  94.       -- APPEND a string to the end of an existing value
  95.       -- PREPEND a string to the beginning of an existing value
  96.       -- REMOVE a substring from within an existing value
  97.  
  98.   Finally, SIT accepts one or more environment-variable
  99. assignments from standard input.  This lets you redirect a text
  100. file into SIT to make several assignments at once, or "pipe" the
  101. output of a program into SIT.  For example, in my AUTOEXEC.BAT
  102. file, I pipe the output of a program that reports the current
  103. system date and time (in a special format) into SIT to set a
  104. variable
  105.  
  106.       DATESTAMP=yymmdd
  107.  
  108. that is used by my program MAKE tool to automatically include
  109. the date a program was assembled or compiled into the program
  110. itself.  This helps to keep track of versions and changes.
  111.  
  112.  
  113. ===== WHY DO YOU CALL IT "SIT"?
  114.  
  115.   'Cuz I feel like it.  However,
  116.  
  117.   1) "SIT" is pretty close to "SET", which is good since they
  118.       do the same kind of work.
  119.  
  120.   2) "sit" is a Latin verb, a form of the verb "esse" (to be).
  121.       (Pluperfect imperative, I think.  Mrs. Ferguson, where
  122.        the heck are you when I _need_ you???)
  123.  
  124.      "sit" means roughly "Let it be" or "Make it so" (with
  125.        apologies to Capt. J.-L. Picard) which is a pretty good
  126.        match to the command "set" (x equal to y).
  127.  
  128.      For example, the motto of the University of Washington is
  129.        LUX SIT  ("Let there be light").  (The rumor that "Lux,
  130.        sit!" is what the Husky cheerleaders say to the mascot
  131.        is, of course, completely unfounded...)
  132.  
  133.  
  134.  
  135. ===== FINE, YOU'RE A NERD IN THREE LANGUAGES.  HOW DO I USE IT?
  136.  
  137. SIT <variable>=<value>
  138.  
  139.     For example,
  140.  
  141.         SIT path=c:\;c:\bin
  142.  
  143.     will either create the variable PATH (if it doesn't
  144.     already exist in the master environment) and assign
  145.     it the value "c:\;c:\bin", or (if it already exists)
  146.     change it from its previous value to "c:\;c:\bin".
  147.  
  148.     Notice that the name of the VARIABLE is forced to
  149.     upper-case ("PATH" rather than "path")... but the
  150.     VALUE keeps the case of the letters you type
  151.     ("c:\;c:\bin" rather than "C:\;C:\BIN")
  152.  
  153.     Since SIT trims the trailing spaces off the variable
  154.     name (which SET doesn't do),
  155.  
  156.         SIT   path    =c:\;c:\bin
  157.  
  158.     does the same thing as the first version.  HOWEVER,
  159.     spaces AFTER the equals sign are significant!
  160.  
  161.         SIT path1  =  c:\; c:\bin
  162.  
  163.     sets the variable PATH1 to the value "  c:\; c:\bin"
  164.     (notice the embedded spaces!)
  165.  
  166.  
  167. SIT <variable>
  168.  
  169.     Reports the current value of VARIABLE, if it exists
  170.     in the master environment.
  171.  
  172.  
  173. SIT <variable>=
  174.  
  175.         Clears VARIABLE out of the master environment if it
  176.     exists.
  177.  
  178.     Notice that the "=" must be the very last thing on the
  179.     command line.  If you follow the "=" with one or more
  180.     spaces, you are setting the value of VARIABLE to "  ".
  181.  
  182.  
  183.  
  184. (Enhanced syntax for SIT)--
  185.  
  186.  
  187. SIT <variable>-=<value>
  188.  
  189.     Removes a substring from an existing value.  If
  190.     VARIABLE exists in the master environment, SIT searches
  191.     its value for the leftmost substring matching <value>
  192.     and chops it out of the value.    For example, if you
  193.  
  194.             SIT ITEM =HUBBA HUBBA
  195.             SIT ITEM -=UBB
  196.  
  197.     then the new value of ITEM is "HA HUBBA" (the second
  198.     command removed the LEFTMOST letters "UBB").
  199.  
  200.     If VARIABLE does not exist, or if <value> is not a
  201.     substring of an existing value, nothing happens.
  202.  
  203.     If the substring removed is the _entire_ existing value,
  204.     SIT eliminates VARIABLE from the environment entirely.
  205.     That is, it treats VARIABLE as though you had said
  206.  
  207.             SIT VARIABLE=
  208.  
  209.     If SIT did not remove the variable, it would leave it in
  210.     the environment but with an empty value -- something that
  211.     could be useful, but isn't the way SET works, so we won't
  212.     work that way either.
  213.  
  214.  
  215.  
  216. SIT <variable>+=<value>
  217.  
  218.     Appends a substring to the END of an existing
  219.     variable, or creates a new variable with the <value>.
  220.  
  221.     For example,
  222.  
  223.         SIT ITEM =HUBBA
  224.         SIT ITEM +=DUBBA
  225.  
  226.     then the new value of ITEM is "HUBBADUBBA" (notice,
  227.     no space!  If you wanted a space, you should have
  228.     said
  229.  
  230.         SIT ITEM += DUBBA
  231.  
  232.     right?)
  233.  
  234.     If VARIABLE doesn't yet exist, SIT += does the same
  235.     thing that SIT = does:
  236.  
  237.         SIT NEWVARIABLE +=BYE BYE BLACKBIRD
  238.  
  239.     (the value of NEWVARIABLE is "BYE BYE BLACKBIRD").
  240.  
  241.  
  242.  
  243. SIT <variable>&=<value>
  244.  
  245.     &= works like +=, except that it PREPENDS the substring
  246.     <value> to the BEGINNING of an existing value. Example:
  247.  
  248.     SIT ITEM=HUBBA          (value is "HUBBA")
  249.     SIT ITEM+=DUBBA        (value is "HUBBADUBBA")
  250.     SIT ITEM-=HUBBA        (value is "DUBBA")
  251.     SIT ITEM&=RUBBA     (value is "RUBBADUBBA")
  252.  
  253.     This is handy for doing things like adjusting your
  254.     PATH.  For example,
  255.  
  256.     SIT PATH &=C:\LOTUS;
  257.  
  258.     will make MS-DOS look for commands first in the
  259.     subdirectory you're in, then in C:\LOTUS, and finally
  260.     in all the subdirectories that were already on the
  261.     PATH... but it will search C:\LOTUS _before_ the
  262.     old PATH subdirectories.
  263.  
  264.  
  265.  
  266. SIT
  267.  
  268.     all by itself accepts Standard Input and interprets it
  269.     line-by-line as if you had typed each line on the SIT
  270.     command line.  For example, you can type
  271.  
  272.            SIT
  273.  
  274.     You may then type lines into SIT and it will process 
  275.     them one by one
  276.  
  277.         path&=c:\lotus
  278.         init+=d:\init;
  279.         include-=d:\work\include;
  280.         ^C
  281.  
  282.     [Ctrl-C], [Ctrl-Z] or [Ctrl-Break] will end the SIT
  283.     session.  You might also have put those three lines
  284.     into a text file called SITSETS.TXT and simply typed
  285.     
  286.         SIT <SITSETS.TXT
  287.         
  288.     to do the same thing.  Finally, you can pipe the
  289.     output of another program into SIT:
  290.     
  291.         UDATE +'datestamp=/%y%m%d" | SIT
  292.         
  293.     causes the variable DATESTAMP to appear in the master
  294.     environment with the value /890421 (assuming that
  295.     today is April 21, 1989...)
  296.  
  297.  
  298.  
  299. ==== CREDENTIALS
  300.  
  301.   I write programs for a living.  (Actually, I write programs
  302. for fun, but my boss seems to get a kick out of giving me a
  303. paycheck, so who am I to argue?)
  304.  
  305.   I also write programs for fun.  (See, I told you!)  And
  306. sometimes I write programs that make it easier to write other
  307. programs.  SIT is a program like that.
  308.  
  309.   I'm publishing SIT for the education of novice programmers,
  310. the amusement of experienced programmers, and in the hopes that
  311. it will someday save someone somewhere half a minute in a batch
  312. file.  It's not particularly complicated, and I'm not looking
  313. for a profit from SIT, so I'm placing it
  314.  
  315.              IN THE PUBLIC DOMAIN
  316.  
  317. which means you're free to do what you want with it -- modify
  318. it, put it inside your own programs, or just have a good laugh
  319. and forget about it.
  320.  
  321.   If you have any comments, suggestions or questions, you can
  322. reach me at
  323.  
  324.           Davidson Corry
  325.       4610 S.W. Lander St.
  326.       Seattle, WA  98116
  327.       (206) 935-0244
  328.  
  329. I don't guarantee to incorporate your ideas, agree with you or
  330. even feel like talking, but usually I'm pretty mellow.
  331. Hope you enjoy SIT.
  332.  
  333.                       -- Daí
  334.  
  335. 5/26/89 update -- 
  336.  
  337.   After the original release of SIT, one of the foolhardy souls
  338. who dared try it discovered that SIT did not work properly with
  339. 4DOS, the new (and excellent) shareware replacement for
  340. COMMAND.COM.  Since I use COMMAND.COM exclusively (because of
  341. some compatibility problems between 4DOS and Novell NetWare), I
  342. didn't discover this.
  343.  
  344.   The problem lies in the way COMMAND.COM takes over some
  345. interrupt vectors.  I assumed that the segment portion of the
  346. INT 2Eh vector (the so-called "back door to COMMAND.COM") would
  347. always point to the master copy of the shell in charge.  I could
  348. then go looking for a memory block that was owned by that
  349. segment and be confident it was my master environment segment.
  350.  
  351.   Turns out it doesn't work that way.  More exactly, COMMAND.COM
  352. _does_ work that way, but 4DOS doesn't.  So, I modified the code
  353. to look for the first memory block that "owns itself" -- that
  354. is, the segment address of the arena header is one less than the
  355. value of the "owner" PSP segment, found at offset [1] into the
  356. arena header.  (Read Ray Duncan's _Advanced_MS-DOS_Programming_
  357. if this doesn't make sense to you -- he explains DOS memory
  358. allocation a lot better than I do...)
  359.  
  360.   Now that I can correctly find the shell-in-charge (be it 4DOS
  361. or COMMAND.COM), I can then confidently look for a master
  362. environment block...   and that turns out to be another can of
  363. worms.
  364.  
  365.   By default, 4DOS does _not_ maintain a "master environment
  366. block" -- instead, it keeps an _internal_ copy if you run 4DOS
  367. in memory-resident mode, or swaps the environment out to EMS or
  368. disk if you are running 4DOS in swapping mode.  Sigh.
  369.  
  370.   Starting with version 2.1, 4DOS allows you to specify a
  371. COMMAND.COM-compatible master environment segment at boot time
  372. (turns out there are _lots_ of programs that need to find the
  373. master environment copy).  SIT has been modified to crap out
  374. gracefully if it can't find the master environment copy. (The
  375. original version just hangs your computer.  Nice, eh?)
  376.  
  377.   So...
  378.   
  379. ==== IF YOU ARE USING SIT WITH 4DOS
  380.  
  381.   You must
  382.   
  383.   1) Use 4DOS version 2.1 (or later).  Version 2.0B and earlier
  384. will _not_ work properly with SIT.
  385.  
  386.   2) Configure 4DOS in swapping mode and use the /M:nnnn switch
  387. to set environment size, rather than the (default) /E:nnnn
  388. switch -- read the 4DOS documents for details.
  389.  
  390.   -- or --
  391.   
  392.   Don't use SIT with 4DOS, and use 4DOS's capabilities to play
  393. with your environment.
  394.